<template>
  <div name="patient">
    <!--列表-->
    <el-table
        ref="multipleTable"
        border
        stripe
        :data="patientList"
        tooltip-effect="dark"
        style="width: 100%">
      <el-table-column
          type="selection"
          width="55">
      </el-table-column>

      <el-table-column
          prop="realName"
          label="姓名"
          width="100">
      </el-table-column>
      <el-table-column
          prop="birthday"
          label="年龄" width="75">
        <template slot-scope="scope">
          {{changeBirthday(scope.row.birthday)}}
        </template>
      </el-table-column>
      <el-table-column
          prop="sex"
          label="性别" width="75">
      </el-table-column>
      <el-table-column
          prop="height"
          label="身高(m)"
          width="75">
      </el-table-column>

      <el-table-column
          prop="weight"
          label="体重(kg)"
          width="85">
      </el-table-column>

      <el-table-column
          label="其他信息"
          width="100">
        <el-button
            slot-scope="scope"
            @click="showMoreInfo(scope.row)">
          查看
        </el-button>
      </el-table-column>

      <el-table-column
          width="260px"
          label="操作">
        <template slot-scope="scope">
          <el-button type="text"
                     @click="editHandle(scope.row.patientId)"
          >编辑</el-button>
        </template>
      </el-table-column>
    </el-table>
  </div>
</template>

<script>

export default {
  name: "patientForm",
  data(){
    return{
      //更多消息窗
      showMoreInfoDig: false,
      //编辑窗
      dialogFormVisible: false,
      //删除键
      delBtnStu: true,

      patientList:[
        {
          patientId: 0,
          realName: '',
          birthday: 0,
          sex: '',
          height: 0.0,
          weight: 0.0,
          operationHistory: '',
          clinicalHistory: '',
          allergy: '',
          userBind: ''
        }
      ],

      editForm: {
        patientId: 0,
        realName: '',
        birthday: 0,
        sex: '',
        height: 0.0,
        weight: 0.0,
        operationHistory: '',
        clinicalHistory: '',
        allergy: '',
        userBind: ''
      },

      editFormRules: {
        username: [
          {required: true, message: '请输入用户名称', trigger: 'blur'}
        ],
        email: [
          {required: true, message: '请输入邮箱', trigger: 'blur'}
        ],
        statu: [
          {required: true, message: '请选择状态', trigger: 'blur'}
        ]
      },
    }
  },
  created() {
    this.getPatientInfo();
  }
  ,method: {
    getPatientInfo(){
      const self = this;

      self.$axios.get('api/patient/accessPatientInfo')
          .then(res=>{
            self.patientList = res.data.data.data;
          })

    },

    delHandle(id) {
      let ids = []
      id ? ids.push(id) : this.multipleSelection.forEach(row => {
        ids.push(row.id)
      })
      console.log(ids)
      let url = 'api/patient/deletePatientInfo'


      this.$axios.post("", ids).then(res => {
        this.$message({
          showClose: true,
          message: '恭喜你，操作成功',
          type: 'success',
          onClose: () => {
            this.getPatientInfo()
          }
        });
      })
    },
    editHandle(id){
      const patientId = id;
      const self = this;
      let json = {
        patientId: patientId
      }

      this.$axios.post('api/patient/selectPatientById', json)
          .then(res => {
            self.editForm = res.data.data;
          }).catch(err => {
            console.log(err);
      })
    },

  }
}
</script>

<style scoped>

</style>